5. processing and sorting machine modular approach 2
现在,让我们开始为我们的站开发代码。
Now, let's start to develop the code for our station.
下一站的指令站只有活塞作为一个装置,它还必须管理进料中的产品,以便允许,呃,产品的进料。
The instruction station next station only has the piston as a device and it also has to manage the products in feed able for to allow the, uh, the feed of products.
那么让我们进入它并进入结构站。
So let's get into it and onto the structure station.
因此,在这里我们必须管理与该站有关的所有状态机。
So here we will have to carry to manage all the state machine for what concerns that station.
因此,我们一如既往地需要一个状态变量,用于我们的状态机以及我们可以创建案例状态的年份。
So what we need is a state variable, as always, for our state machine and the year we can create our case case state of.
好的,让我们在这里添加一些空间,我们的第一个日期是当机器、车站被禁用时。
OK, let's add some space over here, and our first date is when the machine, the station is disabled.
现在我们只查看车站,因此我们实际上可以添加与旧程序中所做的类似的指令。
Right now we are only looking at the station and so we can actually add a similar instruction to what we did in our old program.
没有旧程序。
No old program.
我们说如果。
We said that if.
我们收到了开始按钮,在完成所有其他按钮之后,我们可以移动到另一个状态。
We received the start button, and after all the other buttons here, we can move to another state.
因此,在这个指令站中,我们不会直接查看按钮,而是查看输入。
So here in this struction station, we will not look at the buttons directly, but we will look at our inputs.
因此,如果我们有开始,没有停止,没有紧急情况,没有等待,那么。
So if we have a start and not stop and not emergency and not hold, then.
我们可以到达另一个州。
We can get to another state.
好的。
OK.
当我们到达这里时,这很好。
This is good when we get to our state here.
我们将等待产品,我们在这里能做的首先是启用我们的产品。
We will wait for a product and what we can do over here is, first of all, enable our products.
在 feed 中,他们将其设置为 true。
In feed, they setting it to true.
然后,我们可以在处于禁用状态时为我们设置它,因为我们不希望在我们不工作时出现任何产品,因此我们将认为适合的产品设置为适合并能够抛出。
Then also, we can set it for us whenever we are in the disabled state because we don't want any products appearing when we are not working, so we set the product seen fit to fit and able to throw.
然后,如果我们有一个产品,传感器在这里,等等,让我打开可视化。
And then if we have a product, the sensor over here, wait, let me open the visualisations.
在右边,所以我也可以向您展示一切。
On the right, so I can show you everything as well.
因此,如果我们这里有一个产品,产品和 Pistone 他们回来了,那么 Beston 上的产品开始变得敏感,那么我们可以到达另一个状态,比方说状态 20。
So if we have a product here, product and Pistone them back, so product on Beston starts sensate, then we can get to another state, let's say state 20.
在状态 20 中,我们的活塞上有一个产品,我们实际上可以向前移动该产品。
In this state 20, we have a product on our piston and we can actually move the product forward.
因此,在这种状态下,我们将必须完成贝斯顿向前驱动的移动。
So in this state, we will have the move Beston forward actuation that must be set through.
我们将继续前进,直到我们的产品达到这个生产水平左侧位置。
And we will keep moving forward until our product reaches this production level left position.
所以,Leever 皮卡上的产品已经足够了。
So here we are, enough product on Leever pickup.
这就是传感器的名称。
This is the name of the sensor, then.
我们可以跳到另一个州state duurry。
We can jump to another state state durry.
在状态 30 中,如果。
In state 30, if.
我们已经到达了可以将活塞向后移动的位置,因此向前移动活塞可以等于 false。
We have reached this position where we can move the piston back, so move piston forward can become equal to false.
它需要等于跌倒,我们需要不断返回,直到达到最佳状态并开始该位置。
It will need to be equal to falls and we will need to keep going back until we get to our best and start the position.
森瑟。
Sencer.
这就是基于这个业务起始位置的后面位置,先生,我们实际上已经完成了我们的周期。
That is this based on back position at this business start position, sir, we're actually finished our cycle.
事业有进有退。
The business moved forward and backward.
该项目已被推至低于该水平,因此活塞可以等待一年才能获得另一种产品。
The project has been pushed below the level so the piston can wait a year for another product.
这意味着我们可以在这里跳回状态 10。
This means that we can jump back to state 10 here.
我们可以进行基于移动的回复评论。
We can have a move based back comment.
当我们到达这里时,我们就可以到达该州。
And when we get here, we can get to the state then.
事实上,我们已经管理了与活塞标称循环有关的所有事情。
And we have actually managed everything that concerns the piston nominals cycle.
现在。
Right now.
我们需要管理活塞的停止和活塞的保持以及紧急情况。
We will need to manage, manage both the stopping of the piston and the holding of the piston and also the emergency.
因此,让我们从紧急方式开始,这与我们已经为初始程序编写的方式类似。
So let's start by the emergency way that we that is similar to what we already wrote for the for the initial program.
因此,如果我们按下紧急按钮,那么我们需要做的就是禁用活塞。
So if we press emergency, then what we need to do is actually disable the piston.
活塞向前移动并跳回到等于零的状态,所以我在这里可以做的只是在等于零的状态下添加。
The move piston forward and jump back to state equal to zero, so what I can do over here is simply add in state equal to zero.
贝斯顿的前进应该等于力量。
The move Beston forward should be equal to force.
这就是我们能做的。
This is simply what we can do.
如果机器尚未停止,我们也想这样做。
And also we want to do this if the machine isn't already stopped.
因此,如果状态不为零并且我们正在紧急情况。
So if state is different from zero and we are pressing the emergency.
好的,那么我们需要管理机器的停止。
OK, then we need to manage the stopping of the of our machine.
现在在这里,我实际上可以设置一些注释来将标称状态划分为特殊状态,我们将有停止状态,假设停止状态等于 1000。
Right now here, I can actually set some comment to divide the nominal states to the let's say the special ones here, we will have the stopping state and let's say that the stopping state is equal to 1000.
因此,每当我们按下停止按钮时,我们就会进入等于 1000 的状态,并且我们将再次执行此操作。
So whenever we press the stop button, then we shall go to state equal to one thousand and also we shall do this again.
如果没有,则机器正在运行。
If we are not, the machine is running.
所以我们并不处于等于零的状态。
So we are not in the state equal to zero.
如果我们还没有停止,这意味着状态不等于 1000,并且我们有停止按钮。
And if we are not already stopping, meaning that the state is not equal to 1000 and we have the stop button.
好的,这很好。
OK, this is good.
在停止状态下我们需要做什么?
What do we need to right here in the stopping state.
所以在这里我们实际上可以以更好的方式处理所有事情,这意味着我们实际上可以将人停止在我们想要的任何位置,这意味着如果我们正在执行停止信号,停止操作,这意味着这是一个启动软停止。
So here we can actually handle everything in a better way, meaning that we can actually stop the person in any position that we want, meaning if we are carrying out a stop signal, a stop operation, which means that is a start soft stop.
我们没有进行紧急停止。
We are not carrying out an emergency stop.
事实上,我们现在并不关心活塞是在它的开始还是结束,所以我们实际上可以等待活塞到达它的最终位置,它的位置。
We actually for now, we don't care if the piston is it at its beginning or at its end so we can actually wait for the piston to reach its final position, its position.
我的意思是,活塞在这里或这里都可以。
I mean, it is OK if either the piston is here or here.
所以我们在这里可以做的是,如果我们要向前推进系统,我们需要在这里等待这个传感器。
So what we can do over here is say that if we are moving the system forward, we need to wait for this sensor over here.
所以最后一定很简单,水平的产品,任何拾取的位置,然后我们就停下来,这样我们就可以进入零状态,或者如果我们正在向后移动。
So it must be simple at the end, product for level, position for whatever pickup, then we have stopped so we can go to state zero or if we were moving backwards.
所以我们没有让活塞前进。
So we have not moved Piston forward.
我的意思是,我们还没有推动活塞前进,那么我们需要等待回到这里。
I mean, we have not moved pistons forward, then we need to wait to be back here.
所以我们的条件是停止,以确保我们的活塞确实停止了。
So our condition to stop, to actually be sure that I have our piston actually stopped.
我们不能简单地认为我们在这里并拥有一个基于抱歉的系统和启动位置传感器。
We can't simply have that we are here and have a system sorry based and start position senser.
实际上,现在我们必须改变一些事情,因为如果我们达到零,我们实际上会将其设置为强制。
Actually, right now, we have to change a little thing, because if we get to zero, we will actually set this to force.
因此,如果我们到达这个位置,我们将开始向后移动,而我们可能不希望这样。
So if we got to this position, we will start moving backward and we may not want the.
所以我们需要思考如何管理这个问题。
So we need to think on how to manage this.
因此,我们可以从这里删除这条指令,以避免强制零与贝斯顿向前移动。
So we can remove this instruction from here in order to avoid forcing the zero to be with this move Beston forward.
等于跌倒,我们实际上可以把它放在这里,以确保我们在等待产品时业务不会发生变化。
Equal to falls, and we can actually put it right here to be sure that the business is not moving while we're waiting for products.
再说一次,我们需要把它放在这里,抱歉,当我们进行紧急停止时,就放在这里。
And again, we need to put it right here, sorry, right here when we are carrying out an emergency stop.
好的,那么我们需要管理保持按钮。
OK, then we need to manage the hold button.
因此,让我们以与之前类似的方式执行此操作,我们需要创建一个旧状态,该状态为 500 并且处于此旧状态。
So let's do this in a similar way to what we did before, we need to create an old state that is 500 and is in this old state.
如果我们没有旧的,那么我们就会回到零。
If we do not have the old, then we will get back to zero.
那么让我们看看我们能做什么。
So let's see what we can.
抱歉没有归零。
Sorry not to zero.
我们将回到我们的整个状态。
We will get back to our whole state.
所以让我们按顺序做所有事情。
So let's do everything in order.
没有可行的。
No viable.
我们需要有一个可行的旧状态,它是一个内部整数,并且还保存对该变量的请求。
We need to have an old state viable that is an inside integer and also and hold requests for that variable.
所以下面我们就有了。
So down here we have that.
如果我们不是,那么我们为什么会在这里?
If we are not, let's say why are we here?
我们在旧程序中写道,我们实际上可以复制它,因为这对我们有好处。
Here we wrote in our old program that we can actually copy this because this is good for us.
因此,如果。
So if.
状态不是零和,但我认为这就是不需要括号的原因。
The state is is not zero sum, but I think it's why the brackets are not needed.
我只是希望它们保持一致,所以我们将它们从这里删除。
I just want them to be coherent so we remove them from here.
因此,如果状态不为零、不为 500、不为 1000,并且旧底部被压,我们实际上会这么做。
So if the state is not zero and not 500 and not 1000 and the old bottom is being pressed, we will actually.
设置为要求的 HOLDA。
Set to the HOLDA requested for.
然后看看我们的整个程序,如果我们不处于我们声明的任何非法状态,并且我们还没有保持保持状态并且我们有保持请求,我们将设置请求以强制乙酰状态来说明我们设置状态的原因到 500。
Then looking at our whole program, if we are not in any of these illegal states that we declared and we are not already hold holding and we have a hold request, we will set the request to force acetyl state to state why we set the state to 500.
让我们也来杯测一下吧。
So let's cuppy this as well.
我将在这里删除这一部分,因为实际上我们现在没有任何状态不允许我们持有。
And I will remove this part over here because we actually for now, we have no states that do not allow us to hold.
我们没有任何持续运转的设备,比如桌子,比如盲文,比如电梯。
We do not have any device that keeps on going, such as the table, such as the Braille, such as the elevator.
所以现在,这对我们来说是件好事。
So right now, this is good for us.
让我们在这里添加一些评论。
Let's add some comment here.
这里是应急管理。
Emergency management here.
好吧,停止管理。
All right, stop management.
在这里我们将编写保留管理。
And down here we will write hold management.
然后在这里,我们需要写下,如果我们没有,我们就没有老贝尔滕,抱歉,我认为这里我们没有按钮,而是按住,因为我们依赖于程序的输入。
Then over here, we need to write that if we are not, we do not have the old Berten sorry, and I think here we do not have a button but hold because we are relying on the input of the of the program.
所以在这里,如果我们没有持有,那么我们的状态将成为整个状态,我们保存的那个状态,整个状态将回到零。
So here, if we do not have hold, then our state shall become the whole state, the one that we saved and the whole state shall get back to zero.
好吧,我们几乎为我们的电台做了所有的事情。
OK, we almost did everything for our station.
我们唯一需要管理的是实际的站状态。
The only thing that we need to manage is the actual station state.
这就是我们的输出。
That is our output.
所以我们可以做的是一个 if 语句,根据车站的状态,所以我们可以说,哦,对不起,我有一些疑问。
So what we can do is an if statement, according to the state of the station, so we can say that, oh, sorry, I had some doubt.
我不能说,如果一个状态等于零,那么我们可以将所有这些写在一行中以更加紧凑。
I can't we can say that if a state is equal to zero, then we can write all of this in a single line to be more compact.
因此,每个状态都等于 0,而我们的站状态应等于 0。
So each state is equal to zero than our station state shall be equal to.
我们需要引用枚举的类型如此巨大的状态以至于没有运行,因为当状态等于零时,机器没有运行。
We need to refer to the type of the enumeration so enormous state that not running because when the state is equal to zero, a machine is not running.
在这里,这是正确的,一个难以捉摸的说法,如果我们的州最终等于 500 人死亡,一切都是正确的。
Here, that's right, an elusive statement, and if our state instead is equal to 500 deaths in the end, everything correctly.
那么如果我们的状态等于500,那么我们的站应该处于holding状态。
Then if our state is equal to 500, then our station should be in a holding state.
Al,看看如果我们带来的东西的状态是 1000,那么我们的站状态应该等于。
Al, see if we brought the stuff in condition that is 1000, then our station state shall be equal to.
停止圣..
Stopping St..
我对停止状态感到抱歉,我本想在这里写停止,因为它更连贯,所以。
I'm sorry about stopping state, I meant to write stopping here because it is more coherent, so.
对了,停下来。
Right, stopping.
否则,如果我们不处于其中,如果我们不处于这些状态中的任何一个,这意味着车站的机器正在运行。
Or else, if we are not in it, if we are not in any of these states, this means that the machine at the station is running.
所以站状态应该是running。
So station state should be running.
好吧,那很糟糕。
OK, that's bad.
过来吧。
Come on over here.
大进入西神站状态管理。
Big come into Seishin Station State Management.
好的,如果我写得太快,我会给你一些时间来跟上。
OK, I will give you some time to catch up if I wrote to something too fast.
我们现在不管理故障状态,但我想它稍后会派上用场,因此我们可以构建它。
We are not managing the fault state for now, but I guess but it will come in handy later on so we can build this.
并尝试上网看看会发生什么。
And try to go online and see what happens.
我实际上会在这里打开我们的站调用来查看提取站的状态以及它如何变化。
I will actually open here, our station call to see the state of the extraction station and how it changes.
那么我们就从这里开始程序吧。
So let's start the program here.
看看我是否开始。
See if I start.
机器、工作站正在运行,我们正在推动产品向前发展。
The machine, the station is running and we are pushing products forward.
现在我们将等待,如果我们有一个产品处于提取状态,则不会出现其他产品工作。
And right now we will wait and for now, if we have a product here in the extraction state, no other products work will appear.
如果我们停下来,机器实际上几乎立即停止,因为我们已经回到了阿拉伯斯坦。
And if we stop, the machine actually stopped almost immediately because we had already our Arabistan back.
如果我按开始,它将再次开始。
And if I press start, it will start again.
当我们停下来的时候就停下来。
Stop while we are stopping.
正如我们所看到的,我们就在这里停了下来。
And as we can see, we stopped right here.
那么让我们从苔藓背开始我们的活塞吧。
So let's start our Pistons with the mossback.
和。
And.
我们有能力,一切顺利。
We are able we are good to go.
好的,那么我们吧。
OK, so let's.
尝试一下,他实际上无法尝试握住栏杆,即握住功能,因为我们只做一项任务,而我们想要更多。
Try he actually cannot try the holding of the bar, the holding functionalities, because we are doing only one task and we want more.
我们无法看到会发生什么。
We are not able to see what happens.
我们可以测试紧急情况。
We can test the emergency.
因此,如果我们要向前迈进,那就是在新闻紧急情况下。
So if we are moving forward, then in a press emergency.
正如我们所看到的,产品留在这里。
As we can see, the product is left over here.
好的?
OK?
这很好。
This is good.
我们可以做得更好的另一件事就是这个时候。
Another thing that we can make better is this when.
因此,如果我们消除紧急情况并开始。
So if we remove the emergency and start.
如果我停在这里,你可以看到机器停止了,视差、动物变得真实,但它会再次开始。
If I stop here, you can see that the machine stops and the parallax, the animal becomes true, but it will start again.
您可以看到饲料动物中的产品在活塞返回之前就已经通过了。
You can see that the products in feed animals becomes through before the piston is back.
因此,我们在这里可以做得更好一点的是在这里创建另一种状态,如果活塞尚未返回,则活塞会向后移动。
So what we can do here a little bit better is to create another state here where the piston moves back if it isn't already back.
所以让我们把这个移回来。
So let's move this back.
好吧,假设我们可以直接将这个国家移至顶部,因为这是将巴基斯坦移回顶部的国家。
And well, let's say that we can directly move this state to the top, because this is the state that moves Pakistan back.
所以我们就这样吧。
So let's be like this.
所以 Frosti 为零,我们可以得到状态 5,状态 5 与状态 10 为 10 到状态 20。
So Frosti zero, we can get state five, state five with the state 10 for the 10 to state 20.
来自二十二州。
From state twenty two state.
呃,五,因为这是我们将活塞向后移动的地方。
Uh, five, because this is where we move our piston back.
让我们保存并再次上网。
Let's save and go online again.
看看一切是否正常,请执行下载。
And see if everything works, so please carry out the download.
开始吧。
Let's start.
好的。
OK.
我们在那里,一切似乎都很顺利,让我们按下紧急按钮,好吧,然后重新开始。
We are there and everything seems to be working, let's press the emergency, OK, and start again.
我们就到此为止吧。
Let's stop here.
让我们重新开始。
And let's start again.
好吧,突起,如果有人是假的,好吧,一旦活塞就位,它就变成真的了。
OK, protuberance, if anybody's false, OK, it becomes true once the piston is in position.
好的,这很好。
OK, this is good.
好的,我们设法为我们的提取站创建了程序,我们将为其他站创建下一个视频。
OK, so we managed to create the program for our extraction station and the next videos we will create them, the ones for the other stations.
它会快得多,因为我们实际上可以重用该程序的大部分内容。
It will be much faster because we can actually reuse most of this program.
因此,您也会看到模块化界面的好处。
So we will you will see also this benefit to have a modular interface.